package com.uwang.library.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.alibaba.fastjson.JSON;
import com.uwang.library.model.BtnModel;
import com.uwang.library.model.MemberListModel;
import com.uwang.library.service.BtnService;
import com.uwang.library.service.MemberAddService;
import com.uwang.library.service.MemberListService;
import com.uwang.library.service.impl.BtnServiceImpl;
import com.uwang.library.service.impl.MemberAddServiceImpl;
import com.uwang.library.service.impl.MemberListServiceImpl;

@WebServlet("/memberAdd")
public class MemberAdd extends HttpServlet{
	
	private static final long serialVersionUID = 1L;
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doGet(req, resp);
	}
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		MemberAddService memberAddService = new MemberAddServiceImpl();
//		MemberListService memberListService = new MemberListServiceImpl();
		String userName = req.getParameter("userName");
		String sex = req.getParameter("sex");
		String userPhone = req.getParameter("userPhone");
		String email = req.getParameter("email");
		String enclosure = req.getParameter("enclosure");
		String address = req.getParameter("address");
		String beizhu = req.getParameter("beizhu");
			
			memberAddService.add(userName,sex,userPhone,email,enclosure,address,beizhu);
			resp.getWriter().write("1");
		
		
//		List<MemberListModel> memberList = memberListService.getAllMember();
//		HttpSession session=req.getSession();
//		session.setAttribute("memberList", JSON.toJSONString(memberList));
		
	}
	
	public static void main(String[] args) {
	}
}
